# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=asciidoc
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
conflicts=("${MINGW_PACKAGE_PREFIX}-asciidoc-py3-git")
provides=("${MINGW_PACKAGE_PREFIX}-asciidoc-py3-git")
pkgver=9.0.1
pkgrel=1
pkgdesc="AsciiDoc is a text document format for writing notes, documentation, articles, books, ebooks, slideshows, web pages, man pages and blogs (mingw-w64)"
arch=('any')
url="https://github.com/asciidoc/asciidoc-py3"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-libxslt"
         "${MINGW_PACKAGE_PREFIX}-docbook-xsl")
options=('staticlibs' 'strip')
source=(https://github.com/asciidoc/asciidoc-py3/releases/download/${pkgver}/asciidoc-${pkgver}.tar.gz
        0001-W32-confdir.mingw.patch)
sha256sums=('26ba534b9cc00596febc1b2386fca65d03be0dfbb73f7e1279eeb87637e851c7'
            'e44d1f3a98ef7e06102323843054d7443d833f421bfba55382b961fa9e4691b2')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-W32-confdir.mingw.patch
  autoreconf -fiv
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -rf ${_realname}-${pkgver} build-${MINGW_CHOST}
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 COPYRIGHT  ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYRIGHT
}
